/*
 Navicat Premium Dump SQL

 Source Server         : 本地mysql
 Source Server Type    : MariaDB
 Source Server Version : 120002 (12.0.2-MariaDB-ubu2404)
 Source Host           : localhost:3306
 Source Schema         : db_student

 Target Server Type    : MariaDB
 Target Server Version : 120002 (12.0.2-MariaDB-ubu2404)
 File Encoding         : 65001

 Date: 15/09/2025 17:53:42
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for tb_admin
-- ----------------------------
DROP TABLE IF EXISTS `tb_admin`;
CREATE TABLE `tb_admin` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `username` varchar(32) NOT NULL COMMENT '登录用户名，唯一',
  `password` varchar(128) NOT NULL COMMENT '登录密码（加密存储）',
  `salt` varchar(10) NOT NULL COMMENT '密码盐值',
  `real_name` varchar(64) DEFAULT NULL COMMENT '真实姓名',
  `phone` varchar(32) DEFAULT NULL COMMENT '电话',
  `email` varchar(128) DEFAULT NULL COMMENT '邮箱',
  `status` tinyint(1) DEFAULT 0 COMMENT '状态 0=正常 1=禁用',
  `last_login_time` datetime DEFAULT NULL COMMENT '最后登录时间',
  `create_time` datetime DEFAULT current_timestamp() COMMENT '创建时间',
  `update_time` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '更新时间',
  `remark` varchar(256) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`),
  UNIQUE KEY `ak_username` (`username`),
  KEY `idx_status` (`status`),
  KEY `idx_email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci COMMENT='管理员信息表';

-- ----------------------------
-- Records of tb_admin
-- ----------------------------
BEGIN;
INSERT INTO `tb_admin` (`id`, `username`, `password`, `salt`, `real_name`, `phone`, `email`, `status`, `last_login_time`, `create_time`, `update_time`, `remark`) VALUES (1, 'admin', 'dd6280f074fd17e557cd32c985bdae2e2fa58aedc56d261644509efe951f95e8', '4gGMVB0GEz', '廖老师', '19918787878', 'vsiryxm@qq.com', 0, '2025-09-10 15:06:09', '2025-09-10 15:05:49', '2025-09-10 08:06:26', '这是廖老师的账号');
INSERT INTO `tb_admin` (`id`, `username`, `password`, `salt`, `real_name`, `phone`, `email`, `status`, `last_login_time`, `create_time`, `update_time`, `remark`) VALUES (2, 'admin2', '9a6856968a32f382b7a72a0d0c2574c6933cefb7e4f282324b69d238087bf219', 'ZkoouH5n6b', '张管理员', '19918953639', 'vsiryxm@qq.com', 0, '2025-09-11 19:17:01', '2025-09-11 19:17:01', '2025-09-11 19:17:01', 'hello');
INSERT INTO `tb_admin` (`id`, `username`, `password`, `salt`, `real_name`, `phone`, `email`, `status`, `last_login_time`, `create_time`, `update_time`, `remark`) VALUES (3, 'testadmin', '63a11495c54a60b76337728af46f476618cef36c73d94deb4450d529ab59bb2f', 'bGlA75wNwl', '张3管理员', '13735353636', 'vsiryxm@qq.com', 0, '2025-09-12 10:34:39', '2025-09-12 10:34:39', '2025-09-12 10:34:39', '这里是备注');
INSERT INTO `tb_admin` (`id`, `username`, `password`, `salt`, `real_name`, `phone`, `email`, `status`, `last_login_time`, `create_time`, `update_time`, `remark`) VALUES (4, 'testadmin2', 'dc33ac0e58831764df05ac18368ba8442a2a5c3588566f7b4254e8ae3f05e1ff', 'pgCnHR0uRN', '张管理员', '13735353636', 'vsiryxm@qq.com', 0, '2025-09-12 02:34:39', '2025-09-12 02:34:39', '2025-09-12 02:34:39', '这里是备注');
COMMIT;

-- ----------------------------
-- Table structure for tb_class
-- ----------------------------
DROP TABLE IF EXISTS `tb_class`;
CREATE TABLE `tb_class` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '班级ID',
  `class_name` varchar(64) NOT NULL COMMENT '班级名称',
  `grade_id` bigint(20) NOT NULL COMMENT '年级ID',
  `head_teacher` varchar(64) DEFAULT NULL COMMENT '班主任姓名',
  PRIMARY KEY (`id`),
  KEY `idx_grade_id` (`grade_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1967520268786929672 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci COMMENT='班级表';

-- ----------------------------
-- Records of tb_class
-- ----------------------------
BEGIN;
INSERT INTO `tb_class` (`id`, `class_name`, `grade_id`, `head_teacher`) VALUES (1, '1班', 1, '万卓晴老师');
INSERT INTO `tb_class` (`id`, `class_name`, `grade_id`, `head_teacher`) VALUES (2, '2班', 1, '肖艳鹏老师');
INSERT INTO `tb_class` (`id`, `class_name`, `grade_id`, `head_teacher`) VALUES (3, '3班', 1, '康冬冬老师');
INSERT INTO `tb_class` (`id`, `class_name`, `grade_id`, `head_teacher`) VALUES (4, '4班', 1, '何婷老师');
INSERT INTO `tb_class` (`id`, `class_name`, `grade_id`, `head_teacher`) VALUES (5, '5班', 1, '刘兰云老师');
INSERT INTO `tb_class` (`id`, `class_name`, `grade_id`, `head_teacher`) VALUES (6, '6班', 1, '廖娟老师');
INSERT INTO `tb_class` (`id`, `class_name`, `grade_id`, `head_teacher`) VALUES (7, '7班', 1, '谢伟奇老师');
COMMIT;

-- ----------------------------
-- Table structure for tb_course
-- ----------------------------
DROP TABLE IF EXISTS `tb_course`;
CREATE TABLE `tb_course` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '课程ID',
  `course_name` varchar(64) NOT NULL COMMENT '课程名称',
  `course_desc` varchar(256) DEFAULT NULL COMMENT '课程描述',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci COMMENT='课程表';

-- ----------------------------
-- Records of tb_course
-- ----------------------------
BEGIN;
INSERT INTO `tb_course` (`id`, `course_name`, `course_desc`) VALUES (1, '语文', '');
INSERT INTO `tb_course` (`id`, `course_name`, `course_desc`) VALUES (2, '数学', '');
INSERT INTO `tb_course` (`id`, `course_name`, `course_desc`) VALUES (3, '科学', '');
INSERT INTO `tb_course` (`id`, `course_name`, `course_desc`) VALUES (4, '音乐', '');
INSERT INTO `tb_course` (`id`, `course_name`, `course_desc`) VALUES (5, '美术', '');
INSERT INTO `tb_course` (`id`, `course_name`, `course_desc`) VALUES (6, '体育与健康', '');
INSERT INTO `tb_course` (`id`, `course_name`, `course_desc`) VALUES (7, '道德与法律', '');
COMMIT;

-- ----------------------------
-- Table structure for tb_grade
-- ----------------------------
DROP TABLE IF EXISTS `tb_grade`;
CREATE TABLE `tb_grade` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '年级ID',
  `grade_name` varchar(64) NOT NULL COMMENT '年级名称',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci COMMENT='年级表';

-- ----------------------------
-- Records of tb_grade
-- ----------------------------
BEGIN;
INSERT INTO `tb_grade` (`id`, `grade_name`) VALUES (1, '一年级');
COMMIT;

-- ----------------------------
-- Table structure for tb_score
-- ----------------------------
DROP TABLE IF EXISTS `tb_score`;
CREATE TABLE `tb_score` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `student_no` bigint(20) NOT NULL COMMENT '学生学号',
  `course_id` bigint(20) NOT NULL COMMENT '课程ID',
  `grade_id` bigint(20) NOT NULL COMMENT '年级ID',
  `class_id` bigint(20) NOT NULL COMMENT '班级ID',
  `term_name` tinyint(1) NOT NULL COMMENT '学期名称(1=上学期 2=下学期)',
  `score` decimal(5,2) NOT NULL COMMENT '成绩',
  PRIMARY KEY (`id`),
  UNIQUE KEY `ak_student_no_grade_id_class_id_course_id_term_name` (`student_no`,`grade_id`,`class_id`,`course_id`,`term_name`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci COMMENT='学生成绩表';

-- ----------------------------
-- Records of tb_score
-- ----------------------------
BEGIN;
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (1, 12, 1, 1, 6, 1, 88.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (2, 12, 2, 1, 6, 1, 89.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (3, 12, 3, 1, 6, 1, 98.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (4, 12, 4, 1, 6, 1, 78.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (5, 12, 5, 1, 6, 1, 85.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (6, 12, 6, 1, 6, 1, 100.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (7, 12, 7, 1, 6, 1, 99.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (8, 13, 1, 1, 2, 1, 99.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (9, 13, 2, 1, 2, 1, 98.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (10, 13, 3, 1, 2, 1, 88.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (11, 13, 4, 1, 2, 1, 100.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (12, 13, 5, 1, 2, 1, 84.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (13, 13, 6, 1, 2, 1, 79.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (14, 13, 7, 1, 2, 1, 89.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (15, 35, 1, 1, 1, 1, 100.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (16, 35, 2, 1, 1, 1, 99.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (17, 35, 3, 1, 1, 1, 100.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (18, 35, 4, 1, 1, 1, 98.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (19, 35, 5, 1, 1, 1, 88.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (20, 35, 6, 1, 1, 1, 86.00);
INSERT INTO `tb_score` (`id`, `student_no`, `course_id`, `grade_id`, `class_id`, `term_name`, `score`) VALUES (22, 35, 7, 1, 1, 1, 97.00);
COMMIT;

-- ----------------------------
-- Table structure for tb_student
-- ----------------------------
DROP TABLE IF EXISTS `tb_student`;
CREATE TABLE `tb_student` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `student_no` varchar(32) NOT NULL COMMENT '学号，唯一',
  `first_name` varchar(64) NOT NULL COMMENT '名',
  `last_name` varchar(64) NOT NULL COMMENT '姓氏',
  `gender` char(1) NOT NULL COMMENT '性别 M/F',
  `age` int(11) NOT NULL COMMENT '年龄',
  `birthday` date DEFAULT NULL COMMENT '出生日期',
  `grade_id` bigint(20) NOT NULL COMMENT '年级ID',
  `class_id` bigint(20) NOT NULL COMMENT '班级ID',
  `phone` varchar(32) DEFAULT NULL COMMENT '电话',
  `email` varchar(128) DEFAULT NULL COMMENT '邮箱',
  `address` varchar(256) DEFAULT NULL COMMENT '家庭住址',
  `avatar_url` varchar(256) DEFAULT NULL COMMENT '头像URL',
  `status` tinyint(1) DEFAULT 0 COMMENT '状态 0=正常 1=禁用',
  `create_time` datetime DEFAULT current_timestamp() COMMENT '创建时间',
  `update_time` datetime DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT '更新时间',
  `remark` varchar(256) DEFAULT NULL COMMENT '备注',
  PRIMARY KEY (`id`),
  UNIQUE KEY `ak_student_no` (`student_no`),
  KEY `idx_grade_id` (`grade_id`),
  KEY `idx_class_id` (`class_id`),
  KEY `idx_status` (`status`),
  KEY `idx_email` (`email`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci COMMENT='学生信息表';

-- ----------------------------
-- Records of tb_student
-- ----------------------------
BEGIN;
INSERT INTO `tb_student` (`id`, `student_no`, `first_name`, `last_name`, `gender`, `age`, `birthday`, `grade_id`, `class_id`, `phone`, `email`, `address`, `avatar_url`, `status`, `create_time`, `update_time`, `remark`) VALUES (1, '12', '东晨', '阳', 'M', 7, '2018-11-15', 1, 6, NULL, NULL, NULL, '/uploads/students/612.jpg', 0, '2025-09-15 09:47:38', '2025-09-15 10:53:15', NULL);
INSERT INTO `tb_student` (`id`, `student_no`, `first_name`, `last_name`, `gender`, `age`, `birthday`, `grade_id`, `class_id`, `phone`, `email`, `address`, `avatar_url`, `status`, `create_time`, `update_time`, `remark`) VALUES (2, '13', '俊熹', '李', 'M', 7, '2018-12-08', 1, 2, NULL, NULL, NULL, '/uploads/students/213.jpg', 0, '2025-09-15 09:50:03', '2025-09-15 10:53:17', NULL);
INSERT INTO `tb_student` (`id`, `student_no`, `first_name`, `last_name`, `gender`, `age`, `birthday`, `grade_id`, `class_id`, `phone`, `email`, `address`, `avatar_url`, `status`, `create_time`, `update_time`, `remark`) VALUES (3, '35', '佳宁', '欧', 'F', 7, '2018-10-22', 1, 1, NULL, NULL, NULL, '/uploads/students/135.jpg', 0, '2025-09-15 09:51:41', '2025-09-15 10:53:19', NULL);
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
